package com.atguigu.gmall.item.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "item模块商品详情管理")
@RestController
@RequestMapping("api/item")
public class ItemApiController {
    @Autowired
    private ItemService itemService;

    @ApiOperation(value = "根据skuId获取商品详情相关信息")
    @GetMapping("{skuId}")
    public Result getItemBySkuId(@PathVariable("skuId") Long skuId){
        //调用service层，返回商品详情Map
        Map<String, Object> itemBySkuId = itemService.getItemBySkuId(skuId);
        return Result.ok(itemBySkuId);
    }

}
